/**
 *  @file highScoreController.h
 *
 *  @date 22-dec-2009
 *  @author Ives van der Flaas
 */

#ifndef HIGHSCORECONTROLLER_H_
#define HIGHSCORECONTROLLER_H_

#include <tr1/memory>
#include "highScoreView.h"
#include "highScoreModel.h"

namespace si
{
/**
 * Controls the highscore element.
 * This will load from the model, store to the model,
 * decide if we can add highscores, ...
 */
class HighScoreController
{
public:
	/**
	 * Constructs a HS controller based on a HS model and a
	 * HS view already constructed.
	 * @param hsModel The model for the data
	 * @param view A specific view...
	 * @return
	 */
	HighScoreController(
			std::tr1::shared_ptr<HighScoreModel> hsModel,
			std::tr1::shared_ptr<HighScoreView> view);
	virtual ~HighScoreController();

	/**
	 * Returns true if "score" is high enough to be in the
	 * highscores.
	 * @param score Score of the game you want to know
	 * 				is good enough to get into highscores.
	 * @return True if score is high enough
	 */
	bool canBeInHighScores(int score) const { return fModel->canBeInHighScores(score); }

	/**
	 * Draws the view
	 */
	void draw();

	/**
	 * Adds the highscore combo name-score to highscores.
	 * This WILL NOT test if score is high enough so please
	 * test beforehand.
	 * @param name Name that will be added
	 * @param score Score coupled to that name
	 */
	void addHighScore(std::string name, int score);

private:
	/**
	 * Updates the view when the contents of the model have changed
	 */
	void update();
	std::tr1::shared_ptr<HighScoreModel> fModel;
	std::tr1::shared_ptr<HighScoreView> fView;
};

}

#endif /* HIGHSCORECONTROLLER_H_ */
